package comxin.stringtest;

import org.junit.Test;

public class StringDemo2 {


    @Test
    public void  method01(){
        String s1 = new String("test");
        System.out.println(System.identityHashCode(s1));
        String s2="test";
        s1="test";
        System.out.println(System.identityHashCode(s1));
        System.out.println(System.identityHashCode(s2));
        System.out.println(s1==s2);
    }
    @Test
    public void  method2(){
        char[] chArray={'x','i','n'};
        String s = new String(chArray);
        System.out.println(chArray);
    }



    @Test
    public void method1(){
        //十进制4转成成一个2进制的字符串
        String s = Integer.toString(4, 2);
        //十进制4转成成一个10进制的字符串
        String s1 = Integer.toString(4);
        System.out.println(s1);
        System.out.println(s);

        //0111是一个二进制的字符串 转换成十进制整数
        int i = Integer.parseInt("0111", 2);
        //0111是一个十进制进制的字符串 转换成十进制整数
        System.out.println(Integer.parseInt("0111"));
        System.out.println(i);
    }

}
